import request from '@/utils/request'
// import qs from 'qs'

// 黑名单过滤

// 获取黑名单关键词过滤策略列表
export function getBlacklist (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getBlacklist',
    method: 'post',
    data
  })
}

// 添加黑名单关键词过滤策略
export function addBlacklist (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/addBlacklist',
    method: 'post',
    data
  })
}

// 修改黑名单
export function editBlacklist (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/editBlacklist',
    method: 'post',
    data
  })
}

// 删除黑名单策略信息
export function delBlackInfo (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/delBlackInfo',
    method: 'post',
    data
  })
}

// 获取黑名单关键词过滤策略信息
export function getBlackInfo (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getBlackInfo',
    method: 'post',
    data
  })
}

// 规则

// 获取黑名单关键词过滤策略协议应用列表
export function getBlacklistAgreement (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getBlacklistAgreement',
    method: 'post',
    data
  })
}

// 添加黑名单关键词过滤规则
export function addBlackRule (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/addBlackRule',
    method: 'post',
    data
  })
}

// 删除黑名单关键词过滤策略里的规则
export function delBlackRule (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/delBlackRule',
    method: 'post',
    data
  })
}

// 文件类型

// 获取黑名单文件类型过滤策略列表
export function getBlacklistFile (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getBlacklistFile',
    method: 'post',
    data
  })
}

// 获取黑名单文件类型过滤策略信息
export function getBlackFileInfo (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getBlackFileInfo',
    method: 'post',
    data
  })
}

// 添加黑名单文件类型过滤策略
export function addBlacklistFile (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/addBlacklistFile',
    method: 'post',
    data
  })
}

// 获取黑名单文件过滤策略文件类型列表
export function getBlacklistFileTypeList (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getBlacklistFileTypeList',
    method: 'post',
    data
  })
}

// 编辑黑名单文件类型过滤策略
export function editBlacklistFile (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/editBlacklistFile',
    method: 'post',
    data
  })
}

// 策略管理--获取拦截日志开关
export function getInterceptLogSwitch (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getInterceptLogSwitch',
    method: 'post',
    data
  })
}

// 策略管理--修改拦截日志开关
export function setInterceptLogSwitch (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/setInterceptLogSwitch',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
